This is the alias version of #1749. I.e. we want to make sure that one
can't even create an alias which would end up dangling.
See also: https://pagure.io/releng/issue/7891
Closes: #1768
Approved by: sinnykumari
{
if (remote)
return glnx_throw (error, "Cannot create alias to remote ref: %s", remote);
+ if (!g_hash_table_contains (refs, refspec_prefix))
+ return glnx_throw (error, "Cannot create alias to non-existent ref: %s",
+ refspec_prefix);
if (!ostree_repo_set_alias_ref_immediate (repo, remote, ref, refspec_prefix,
cancellable, error))
goto out;
setup_fake_remote_repo1 "archive"
-echo '1..6'
+echo '1..7'
cd ${test_tmpdir}
mkdir repo
fi
assert_file_has_content_literal err.txt 'Cannot create alias to remote ref'
echo "ok ref no alias remote"
+
+if ${CMD_PREFIX} ostree --repo=repo refs -A --create foobar nonexistent 2>err.txt; then
+ fatal "Created alias to nonexistent ref?"
+fi
+assert_file_has_content_literal err.txt 'Cannot create alias to non-existent ref'
+echo "ok ref no broken alias"